package com.goverse.mancraft.man.action;

import android.os.Handler;
import android.os.Looper;

import com.goverse.mancraft.man.Man;
import com.goverse.mancraft.man.ManController;

/**
 * Created by gaoyu on 2017/4/15.
 */

public abstract class AbstractAction {

    protected Man mMan = null;

    public AbstractAction() {
    }

    public enum Action {
        SLEEP,
        NORMAL,
        WORK
    }

    public void wakeUp() {
        mManController.wakeUp(mMan);
    }

    public void setMan(Man man) {
        mMan = man;
    }

    private ManController mManController = null;

    public void setManController(ManController manController) {
        mManController = manController;
    }

    public abstract int getLoseHp();

    public void onStop() {
        mHandler.removeCallbacks(mTimeThread);
    }

    public abstract void onStart();

    public void doAction(AbstractAction action) {
        mManController.doAction(mMan, action);
    }

    protected Handler mHandler =  new Handler();


    private Runnable mTimeThread = new Runnable() {
        @Override
        public void run() {
            onStop();
        }
    };

    private int mTime = 0;

    public void doTime(int time) {
        mTime = time;
        mHandler.postDelayed(mTimeThread, mTime * 1000);
    }
}
